<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_Panic manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> Panic</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<DL>
<DD><A HREF="Panic.htm#M2" NAME="L584">NAME</A>
<DL><DD>Tcl_Panic, Tcl_PanicVA, Tcl_SetPanicProc &mdash; report fatal error and abort</DD></DL>
<DD><A HREF="Panic.htm#M3" NAME="L585">SYNOPSIS</A>
<DL>
<DD><B>#include &lt;tcl.h&gt;</B>
<DD>void
<DD><B>Tcl_Panic</B>(<I>format</I>, <I>arg</I>, <I>arg</I>, <I>...</I>)
<DD>void
<DD><B>Tcl_PanicVA</B>(<I>format</I>, <I>argList</I>)
<DD>void
<DD><B>Tcl_SetPanicProc</B>(<I>panicProc</I>)
</DL>
<DD><A HREF="Panic.htm#M4" NAME="L586">ARGUMENTS</A>
<DL class="arguments">
</DL>
<DD><A HREF="Panic.htm#M5" NAME="L587">DESCRIPTION</A>
<DD><A HREF="Panic.htm#M6" NAME="L588">SEE ALSO</A>
<DD><A HREF="Panic.htm#M7" NAME="L589">KEYWORDS</A>
</DL>
<H3><A NAME="M2">NAME</A></H3>
Tcl_Panic, Tcl_PanicVA, Tcl_SetPanicProc &mdash; report fatal error and abort
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
void<BR>
<B>Tcl_Panic</B>(<I>format</I>, <I>arg</I>, <I>arg</I>, <I>...</I>)<BR>
void<BR>
<B>Tcl_PanicVA</B>(<I>format</I>, <I>argList</I>)<BR>
void<BR>
<B>Tcl_SetPanicProc</B>(<I>panicProc</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT>const char* <B><A HREF="../TclCmd/format.htm">format</A></B> (in)<DD>
A printf-style format string.
<P><DT><B>arg</B> (in)<DD>
Arguments matching the format string.
<P><DT>va_list <B>argList</B> (in)<DD>
An argument list of arguments matching the format string.
Must have been initialized using <B>va_start</B>,
and cleared using <B>va_end</B>.
<P><DT>Tcl_PanicProc <B>*panicProc</B> (in)<DD>
Procedure to report fatal error message and abort.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
When the Tcl library detects that its internal data structures are in an
inconsistent state, or that its C procedures have been called in a
manner inconsistent with their documentation, it calls <B>Tcl_Panic</B>
to display a message describing the error and abort the process.  The
<I>format</I> argument is a format string describing how to format the
remaining arguments <I>arg</I> into an error message, according to the
same formatting rules used by the <B>printf</B> family of functions.  The
same formatting rules are also used by the built-in Tcl command
<B><A HREF="../TclCmd/format.htm">format</A></B>.
<P>
In a freshly loaded Tcl library, <B>Tcl_Panic</B> prints the formatted
error message to the standard error file of the process, and then
calls <B>abort</B> to terminate the process.  <B>Tcl_Panic</B> does not
return. On Windows, when a debugger is running, the formatted error
message is sent to the debugger instead. If the windows executable
does not have a stderr channel (e.g. <B>wish.exe</B>), then a
system dialog box is used to display the panic message.
<P>
<B>Tcl_SetPanicProc</B> may be used to modify the behavior of
<B>Tcl_Panic</B>.  The <I>panicProc</I> argument should match the
type <B>Tcl_PanicProc</B>:
<P>
<PRE>typedef void <B>Tcl_PanicProc</B>(
        const char *<B><A HREF="../TclCmd/format.htm">format</A></B>,
        <B>arg</B>, <B>arg</B>,...);</PRE>
<P>
After <B>Tcl_SetPanicProc</B> returns, any future calls to
<B>Tcl_Panic</B> will call <I>panicProc</I>, passing along the
<I>format</I> and <I>arg</I> arguments. <I>panicProc</I> should avoid
making calls into the Tcl library, or into other libraries that may
call the Tcl library, since the original call to <B>Tcl_Panic</B>
indicates the Tcl library is not in a state of reliable operation.
<P>
The typical use of <B>Tcl_SetPanicProc</B> arranges for the error message
to be displayed or reported in a manner more suitable for the
application or the platform.
<P>
Although the primary callers of <B>Tcl_Panic</B> are the procedures of
the Tcl library, <B>Tcl_Panic</B> is a public function and may be called
by any extension or application that wishes to abort the process and
have a panic message displayed the same way that panic messages from Tcl
will be displayed.
<P>
<B>Tcl_PanicVA</B> is the same as <B>Tcl_Panic</B> except that instead of
taking a variable number of arguments it takes an argument list.
<H3><A NAME="M6">SEE ALSO</A></H3>
<B>abort</B>, <B>printf</B>, <B><A HREF="../TclCmd/exec.htm">exec</A></B>, <B><A HREF="../TclCmd/format.htm">format</A></B>
<H3><A NAME="M7">KEYWORDS</A></H3>
<A href="../Keywords/A.htm#abort">abort</A>, <A href="../Keywords/F.htm#fatal">fatal</A>, <A href="../Keywords/E.htm#error">error</A>
<div class="copy"></div>
</BODY></HTML>
